#ifndef __EKOS_KERNEL_SYS_H__
#define __EKOS_KERNEL_SYS_H__

typedef uint16_t cpu_id_t;

#define PRIORITY_COUNT 31

struct cpu_t
{
	 int valid;
	 proc_id_t idle_pid;
	 physaddr_t vpt;
	 
	 uint32_t rq_bits;
	 uint32_t rq_cur;
	 proc_id_t rq_head[PRIORITY_COUNT + 1];

	 spin_lock_t ipi_recv_lock;
	 cpu_id_t ipi_source;
	 int ipi_func;
	 int ipi_arg0;
	 int ipi_arg1;
	 int ipi_arg2;
	 int ipi_arg3;
	 spin_lock_t ipi_send_lock;
	 
	 /* Initialized by task_init() */
	 volatile struct taskstate_t *task;
};

/* The ID of the BSP */
extern struct sysconf_t sysconf;
extern cpu_id_t cpu_ids[SMP_MAX_COUNT];
extern volatile struct cpu_t cpus[SMP_MAX_COUNT];

/* Get the system config for EKOS, get the address of LAPIC and IO APIC */
int sys_init();
/* Get the current cpu id by reading the LAPIC register */
int cur_cpu();

#endif
